<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateTableContent extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {
        $this->execute("CREATE TABLE `f_content` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
            `title` varchar(45) NOT NULL,
            `sub_title` varchar(45) DEFAULT NULL COMMENT '副标题',
            `source` varchar(45) DEFAULT NULL COMMENT '来源',
            `author` varchar(45) DEFAULT NULL COMMENT '作者',
            `intro` varchar(100) DEFAULT NULL COMMENT '简介',
            `content` text COMMENT '内容',
            `images` text COMMENT '图片json数据',
            `redirect_url` varchar(145) DEFAULT NULL COMMENT '跳转地址',
            `redirect` enum('yes','no') DEFAULT 'no' COMMENT '是否跳转',
            `cover` varchar(145) DEFAULT NULL COMMENT '封面图片',
            `category` varchar(45) DEFAULT NULL COMMENT '分类',
            `hits` int(11) DEFAULT '0' COMMENT '点击量',
            `top` enum('yes','no') DEFAULT 'no' COMMENT '是否置顶\n',
            `position` int(11) DEFAULT '1' COMMENT '推荐位',
            `author_id` int(11) DEFAULT NULL COMMENT '作者id',
            `publish_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '发布时间',
            `create_time` int(11) DEFAULT NULL,
            `update_time` int(11) DEFAULT NULL,
            `is_delete` enum('yes','no') DEFAULT 'no',
            `goods` int(11) DEFAULT '0' COMMENT '点赞数',
            `area` varchar(12) DEFAULT NULL COMMENT '地区',
            `status` enum('published','draft','delete') DEFAULT 'draft' COMMENT '状态',
            `tags` varchar(145) DEFAULT NULL COMMENT '逗号分隔的标签',
            `delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
            `comment` enum('allow','disallow') DEFAULT 'disallow',
            PRIMARY KEY (`id`)
          ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='内容表';
          ");
    }
    public function down()
    {
        $this->execute("drop table `f_content`;");
    }
}
